package Transport

import (
	"context"
	"encoding/json"
	"errors"
	"net/http"
	"strconv"
	"sz_client/Endpoint"
)

func GetUserInfo_Request(c context.Context, request *http.Request, r interface{}) error {
	userRequest := r.(Endpoint.Request)
	request.URL.Path += "/user/"+strconv.Itoa(userRequest.Uid)
	return nil
//http://localhost:8080/user/211
}

func GetUserInfo_Response(c context.Context, res *http.Response) (response interface{}, err error) {
	if res.StatusCode > 400 {
		return nil, errors.New("没有数据")
	}
	var user_response Endpoint.Response
	err = json.NewDecoder(res.Body).Decode(&user_response)
	if err != nil {
		return nil, err
	}
	return user_response, err
}